import {baseURL,defaultLang} from "./config";
import Http from './http';
const http = new Http();
http.config.baseURL = baseURL;
http.config.debug=true
http.interceptor.request = config => {
	const token = uni.getStorageSync("token");
	if(token){
		config.header['token']=token
	}
	const lang=uni.getStorageSync("lang")?uni.getStorageSync("lang"):defaultLang
	config.data['lang']=lang
	config.header['lang']=lang
	return config;
}
// 响应拦截器
http.interceptor.response = response => {
	const data=response.data
	if(data.code==401){
		uni.redirectTo({
			url:'/pages/login/loginbypass'
		})
	}
	return response.data;
}
export default http;